<?php
//include database connection
include '../lib/database.php';

try{
	//write query
	$query = "INSERT INTO tbl_aspirante SET tbl_municipio_tbl_departamento_id_departamento = ?, tbl_municipio_id_municipio = ?, nombres = ?, apellidos = ?, email = ?, genero = ?, fecha_nacimiento  = ?, domicilio = ?, tel_casa = ?, tel_oficina = ?, tel_celular = ?, url_cv= ?, login = ?, clave = ?, carrera = ?, nivel_academico = ?, cum = ?";
	$con = Database::connect();
	//prepare query for excecution
	$stmt = $con->prepare($query);

	//bind the parameters
	//this is the first question mark
	$depa = 1;
	$municipio = 1;
	$fechaNacimiento = '1985-05-04';
	$urlCV = 'dfdsfsdfsd';
	// Depa y Municipio
	$stmt->bindParam(1, $depa);
	$stmt->bindParam(2, $municipio);

	// Nombres
	$stmt->bindParam(3, $_POST['nombres']);
	
	//Email
	$stmt->bindParam(4, $_POST['apellidos']);

	//Email
	$stmt->bindParam(5, $_POST['email']);

	//Genero
	$stmt->bindParam(6, $_POST['genero']);
	
	//Fecha Nacimiento
	$stmt->bindParam(7, $fechaNacimiento);
	
	//Domicilio
	$stmt->bindParam(8, $_POST['domicilio']);
	

	//Tel Casa
	$stmt->bindParam(9, $_POST['telCasa']);
	
	//Tel Oficina
	$stmt->bindParam(10, $_POST['telOficina']);	

	//Tel Celuar
	$stmt->bindParam(11, $_POST['telCelular']);
	
	//URL CV
	$stmt->bindParam(12, $urlCV);
	
	//Login
	$stmt->bindParam(13, $_POST['login']);
	
	//Clave
	$stmt->bindParam(14, $_POST['clave']);
	
	
	//Carrera
	$stmt->bindParam(15, $_POST['carrera']);
	
	//Nivel Academico
	$stmt->bindParam(16, $_POST['nivelAcademico']);
	
	//CUM
	$stmt->bindParam(17, $_POST['cum']);
	
	
	
	// Execute the query
	if($stmt->execute()){
		echo "User was created.";
	}else{
		echo "Unable to created user.";
	}
}

//to handle error
catch(PDOException $exception){
	echo "Error: " . $exception->getMessage();
}
?>